home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.text;
-
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.beans.PropertyChangeEvent;
- import java.beans.PropertyChangeListener;
- import javax.swing.SwingUtilities;
- import javax.swing.event.DocumentEvent;
- import javax.swing.event.DocumentListener;
- import javax.swing.text.Position.Bias;
-
- class DefaultCaret$UpdateHandler implements PropertyChangeListener, DocumentListener, ActionListener {
- // $FF: synthetic field
- private final DefaultCaret this$0;
-
- DefaultCaret$UpdateHandler(DefaultCaret var1) {
- this.this$0 = var1;
- }
-
- public void actionPerformed(ActionEvent var1) {
- if (this.this$0.visible || this.this$0.width != 0 && this.this$0.height != 0) {
- this.this$0.visible ^= true;
- this.this$0.repaint();
- } else {
- this.this$0.setVisible(true);
- }
-
- }
-
- public void changedUpdate(DocumentEvent var1) {
- }
-
- public void insertUpdate(DocumentEvent var1) {
- if (this.this$0.async || SwingUtilities.isEventDispatchThread()) {
- int var2 = 0;
- int var3 = var1.getOffset();
- int var4 = var1.getLength();
- if (this.this$0.dot >= var3) {
- var2 = var4;
- }
-
- if (this.this$0.mark >= var3) {
- DefaultCaret var10000 = this.this$0;
- var10000.mark += var4;
- }
-
- if (var2 != 0) {
- if (this.this$0.dot == var3) {
- Document var5 = this.this$0.component.getDocument();
- int var6 = this.this$0.dot + var2;
-
- boolean var7;
- try {
- var7 = var5.getText(var6 - 1, 1).equals("\n");
- } catch (BadLocationException var8) {
- var7 = false;
- }
-
- if (var7) {
- this.this$0.changeCaretPosition(var6, Bias.Forward);
- } else {
- this.this$0.changeCaretPosition(var6, Bias.Backward);
- }
- } else {
- this.this$0.changeCaretPosition(this.this$0.dot + var2, this.this$0.dotBias);
- }
- }
- }
-
- }
-
- public void propertyChange(PropertyChangeEvent var1) {
- Object var2 = var1.getOldValue();
- Object var3 = var1.getNewValue();
- if (var2 instanceof Document || var3 instanceof Document) {
- this.this$0.setDot(0);
- if (var2 != null) {
- ((Document)var2).removeDocumentListener(this);
- }
-
- if (var3 != null) {
- ((Document)var3).addDocumentListener(this);
- }
- }
-
- }
-
- public void removeUpdate(DocumentEvent var1) {
- if (this.this$0.async || SwingUtilities.isEventDispatchThread()) {
- int var2 = 0;
- int var3 = var1.getOffset();
- int var4 = var3 + var1.getLength();
- boolean var5 = false;
- if (this.this$0.dot >= var4) {
- var2 = var4 - var3;
- if (this.this$0.dot == var4) {
- var5 = true;
- }
- } else if (this.this$0.dot >= var3) {
- var2 = this.this$0.dot - var3;
- var5 = true;
- }
-
- boolean var6 = false;
- if (this.this$0.mark >= var4) {
- DefaultCaret var10000 = this.this$0;
- var10000.mark -= var4 - var3;
- if (this.this$0.mark == var4) {
- var6 = true;
- }
- } else if (this.this$0.mark >= var3) {
- this.this$0.mark = var3;
- var6 = true;
- }
-
- if (this.this$0.mark == this.this$0.dot - var2) {
- this.this$0.setDot(this.this$0.dot - var2, this.this$0.guessBiasForOffset(this.this$0.dot - var2, this.this$0.dotBias, this.this$0.dotLTR));
- } else {
- if (var5) {
- this.this$0.dotBias = this.this$0.guessBiasForOffset(this.this$0.dot - var2, this.this$0.dotBias, this.this$0.dotLTR);
- }
-
- if (var6) {
- this.this$0.markBias = this.this$0.guessBiasForOffset(this.this$0.mark, this.this$0.markBias, this.this$0.markLTR);
- }
-
- this.this$0.changeCaretPosition(this.this$0.dot - var2, this.this$0.dotBias);
- this.this$0.markLTR = this.this$0.isPositionLTR(this.this$0.mark, this.this$0.markBias);
- }
- }
-
- }
- }
-